package com.qzimp.fujiancuo.mapper;

import com.qzimp.fujiancuo.entity.Reservation;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface ReservationMapper {

        // 根据 reservationId 获取 Reservation
        @Select("SELECT * FROM tb_reservation WHERE reservation_id = #{reservationId}")
        Reservation getReservationById(Long reservationId);

        // 获取某个访客的所有预约
        @Select("SELECT * FROM tb_reservation WHERE visitor_id = #{visitorId}")
        List<Reservation> getReservationsByVisitorId(Long visitorId);

        // 添加预约
        @Insert("INSERT INTO tb_reservation(visitor_id, visit_date,  status) " +
                "VALUES(#{visitorId}, #{visitDate},  #{status})")
        void addReservation(Reservation reservation);

        // 删除预约
        @Delete("DELETE FROM tb_reservation WHERE reservation_id = #{reservationId}")
        void deleteReservation(Long reservationId);

        // 修改预约状态
        @Update("UPDATE tb_reservation SET status = #{status} WHERE reservation_id = #{reservationId}")
        void updateReservationStatus(@Param("reservationId") Long reservationId, @Param("status") String status);
}